package com.xy.biz.fd.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.fd.domain.bo.DocumentCodePoolBO;
import com.xy.biz.fd.domain.po.DocumentCodePoolPO;
import com.xy.biz.fd.domain.query.DocumentCodePoolQuery;
import com.xy.biz.fd.domain.resp.GetDocumentCodePoolResponse;
import com.xy.biz.fd.domain.req.SaveDocumentCodePoolRequest;
import com.xy.biz.fd.domain.req.ListDocumentCodePoolRequest;

/**
 * 
 * 
 * @author zgy
 * @date 2021-6-11
 */
public class DocumentCodePoolConverter {
	
	public static DocumentCodePoolPO toPO(DocumentCodePoolBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentCodePoolPO(), true);
	}
	
	public static List<DocumentCodePoolPO> toPO(Collection<DocumentCodePoolBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentCodePoolPO(), true);
	}
	
	public static DocumentCodePoolBO fromPO(DocumentCodePoolPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentCodePoolBO());
	}
	
	public static List<DocumentCodePoolBO> fromPO(Collection<DocumentCodePoolPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentCodePoolBO());
	}
	
	public static DocumentCodePoolBO toBO(SaveDocumentCodePoolRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentCodePoolBO(), true);
	}
	
	public static List<DocumentCodePoolBO> toBO(Collection<SaveDocumentCodePoolRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentCodePoolBO(), true);
	}
	
	public static GetDocumentCodePoolResponse toResponse(DocumentCodePoolBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetDocumentCodePoolResponse());
	}
	
	public static List<GetDocumentCodePoolResponse> toResponse(Collection<DocumentCodePoolBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetDocumentCodePoolResponse());
	}
	
	public static DocumentCodePoolQuery toQuery(ListDocumentCodePoolRequest source) {
		if(null == source) {
			return null;
		}
		DocumentCodePoolQuery target = new DocumentCodePoolQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
